var width
    export default class bg extends Laya.Script {

    // 更多参数说明请访问: https://ldc2.layabox.com/doc/?nav=zh-as-2-4-0
    owner=this.owner as Laya.Sprite;
    start=false;
    constructor() { super(); }
    
onAwake(){
    Laya.stage.on("gamerover",this,function(){this.start=false;this.owner.getComponent(Laya.RigidBody).linearVelocity={x:0,y:0}})
    Laya.stage.on("start",this,function(){this.start=true;})
    width=this.owner.width;
}
onUpdate(){
    if(!this.start)return;
    this.owner.getComponent(Laya.RigidBody).linearVelocity={x:-20,y:0}
    if(this.owner.x<=-width){
        this.owner.x+=width*2;
        }
}
}